<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 *
 */

$common_func = new CommonFunctions();
$payPeriodList = $this->popArr['payPeriodList'];
?>
<script type="text/javaScript"><!--//--><![CDATA[//><!--
function decimalCurr(txt) {
	regExp = /^[0-9]+(\.[0-9]+)*$/;

	return regExp.test(txt.value);
}

var currency = new Array();

function addEXTPayment() {

	/*if(document.frmEmp.cmbCurrCode.value=='0') {
			alert("<?php echo $lang_Error_FieldShouldBeSelected; ?>!");
			document.frmEmp.cmbCurrCode.focus();
			return;
	}*/

	/*var cnt=document.frmEmp.txtBasSal;
	if(!decimalCurr(cnt)) {
		alert("<?php echo $lang_Error_FieldShouldBeNumeric; ?>");
		cnt.focus();
		return;
	}*/

//	var min = eval(document.frmEmp.txtMinCurrency.value);
//	var max = eval(document.frmEmp.txtMaxCurrency.value);
//
//	if(min > cnt.value || max < cnt.value) {
//		alert("<?php echo $lang_hremp_SalaryShouldBeWithinMinAndMa; ?>");
//		cnt.focus();
//		return;
//	}

document.frmEmp.paymentSTAT.value="ADD";
qCombo(14);
}

function editEXTPayment() {

	/*if(document.frmEmp.cmbCurrCode.value=='0') {
			alert("<?php echo $lang_Error_FieldShouldBeSelected; ?>!");
			document.frmEmp.cmbCurrCode.focus();
			return;
	}*/

	/*var cnt=document.frmEmp.txtBasSal;
	if(!decimalCurr(cnt)) {
		alert("<?php echo $lang_Error_FieldShouldBeNumeric; ?>");
		cnt.focus();
		return;
	}*/

//	var error = false;
//	var min = eval(document.frmEmp.txtMinCurrency.value);
//	var max = eval(document.frmEmp.txtMaxCurrency.value);
//
//	if(min > cnt.value || max < cnt.value) {
//		alert("<?php echo $lang_hremp_SalaryShouldBeWithinMinAndMa; ?>");
//		cnt.focus();
//		return;
//	}

	/*for(i=0;i<=currency.length;i++){
		if(document.getElementById('cmbCurrCode').value == currency[i]){			
			error = true;
			break;
		}		
	}
	
	if(error == true){
		alert('<?php echo $lang_hremp_Currency_is_already_exist; ?>');
	}*/
	
  document.frmEmp.paymentSTAT.value="EDIT";
  qCombo(14);
}

function delEXTPayment() {

	var check = false;
	with (document.frmEmp) {
		for (var i=0; i < elements.length; i++) {
			if ((elements[i].name == 'chkpaydel[]') && (elements[i].checked == true)) {
				check = true;
			}
		}
	}

	if(!check) {
		alert('<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>')
		return;
	}

    document.frmEmp.paymentSTAT.value="DEL";
	qCombo(14);
}

function resetForm() {
	$('frmEmp').reset();
	setCurrCode();
}

function viewPayment(pay,curr) {

	document.frmEmp.action = document.frmEmp.action + "&PAY=" + pay + "&CUR=" + curr;
	document.frmEmp.pane.value = 14;
	document.frmEmp.submit();
}//--><!]]></script>
<?php
$supervisorEMPMode = false;
if ((isset($_SESSION['isSupervisor']) && $_SESSION['isSupervisor']) && (isset($_GET['reqcode']) && ($_GET['reqcode'] === "EMP")) ) {
	$supervisorEMPMode = true;
}
if(isset($this->getArr['capturemode']) && $this->getArr['capturemode'] == 'updatemode') { ?>
<div id="parentPanePayments" >
        <input type="hidden" name="paymentSTAT" value=""/>
<?php
	$salGrd = $this->popArr['salGrd'];
//	if($salGrd === null) {
//		$pleaseSelectJobTitle = preg_replace('/\{(.*)\}/', "<a href='javascript:displayLayer(2)'>$1</a>", $lang_hremp_PleaseSelectJobTitle);
//		echo "<p align='center'><strong>$lang_hremp_AddPayGrade</strong></p>";
//	}
?>
<?php
	if(isset($this->popArr['editPaymentArr'])) {
	 	$edit = $this->popArr['editPaymentArr'];
?>
<input type="hidden" id="oldSalaryGrade" name="oldSalaryGrade" value="<?php echo $this->popArr['salGrd']; ?>">
<input type="hidden" id="oldCurrency" name="oldCurrency" value="<?php echo @$edit['currency_id']; ?>">
<input type="hidden" id="oldetxtBasSal" name="oldetxtBasSal" value="<?php echo $common_func->formatSciNo(@$edit[3]);?>">
	<div id="editPanePayments">
 			<table width="100%" border="0" cellpadding="5" cellspacing="0" class="">
        		
					  <tr>
						<td valign="top">职位</td>
						<td align="left" valign="top"><?php echo $this->popArr['emp_job'][0];?></td>
					  </tr>
					  <tr>
						<td valign="top">职位津贴</td>
						<td align="left" valign="top"><input type="text" name="txtJobPay" id="txtJobPay" value="<?php echo $this->popArr['emp_job'][1];?>" readonly/>
						</td>
					  </tr>
					  <!--tr>
						<td valign="top">调薪前职位薪水</td>
						<td align="left" valign="top"><input type="text" name="txtLastBasSal" id="etxtLastBasSal" value="<?php echo $common_func->formatSciNo(@$edit[4]);?>"/>
						</td>
					  </tr-->
					  <tr>
						<td valign="top">时薪</td>
						<td align="left" valign="top">
							<select name="txtDaySalId" id="etxtDaySalId">
								<option selected="selected" value="0">-----选择时薪标准-------</option>
<?php
							$daysalarylist = $this->popArr['daysalarylist'];
							for($c=0;$daysalarylist && count($daysalarylist)>$c;$c++)
								if ($daysalarylist[$c][0]==@$edit[19]) {
									echo "<option value='" . $daysalarylist[$c][0] . "' selected='selected'>" . $daysalarylist[$c][1] . " - " . $daysalarylist[$c][2] . "</option>";
								}else {
									echo "<option value='" . $daysalarylist[$c][0] . "'>" . $daysalarylist[$c][1] . " - " . $daysalarylist[$c][2] . "</option>";
								}
?>
							</select>
						</td>
					  </tr>
					  <!--tr>
						<td valign="top">时薪</td>
						<td align="left" valign="top"><input type="text" name="txtBasSal" id="etxtBasSal" value="<?php echo $common_func->formatSciNo(@$edit[3]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">年功加薪</td>
						<td align="left" valign="top"><input type="text" name="txtLongevityPay" id="txtLongevityPay" value="<?php echo $common_func->formatSciNo(@$edit[15]);?>"/>
						</td>
					  </tr-->
					  <tr>
						<td valign="top">学历</td>
						<td align="left" valign="top"><?php echo $this->popArr['emp_edu'][0];?></td>
					  </tr>
					  <tr>
						<td valign="top">学历加薪(元)</td>
						<td align="left" valign="top"><input type="text" name="txtEduPay" id="txtEduPay" value="<?php echo $this->popArr['emp_edu'][1];?>" readonly/>
						</td>
					  </tr>
					  <!--tr>
						<td valign="top">等级津贴</td>
						<td align="left" valign="top"><input type="text" name="txtAdmPay" id="txtAdmPay" value="<?php echo $common_func->formatSciNo(@$edit[17]);?>"/>
						</td>
					  </tr-->
					  <tr>
						<td valign="top">技能津贴</td>
						<td align="left" valign="top"><input type="text" name="txtTecPay" id="txtTecPay" value="<?php echo $this->popArr['emp_tec'];?>" readonly/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">等级津贴</td>
						<td align="left" valign="top"><input type="text" name="txtAdmPay" id="txtAdmPay" value="<?php echo $this->popArr['emp_adm'];?>" readonly/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">高温津贴</td>
						<td align="left" valign="top"><input type="text" name="txtTempAllo" id="etxtTempAllo" value="<?php echo $common_func->formatSciNo(@$edit[5]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">夜班津贴</td>
						<td align="left" valign="top"><input type="text" name="txtNightAllo" id="etxtNightAllo" value="<?php echo $common_func->formatSciNo(@$edit[6]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">其他津贴</td>
						<td align="left" valign="top"><input type="text" name="txtOtherAllo" id="etxtOtherAllo" value="<?php echo $common_func->formatSciNo(@$edit[7]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">其他津贴说明</td>
						<td align="left" valign="top"><textarea name="txtOtherAlloRemark" id="etxtOtherAlloRemark"><?php echo $common_func->formatSciNo(@$edit[13]);?></textarea>
						</td>
					  </tr>
					  <tr>
						<td valign="top">养老保险</td>
						<td align="left" valign="top"><input type="text" name="txtEndowIns" id="etxtEndowIns" value="<?php echo $common_func->formatSciNo(@$edit[10]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">医疗保险</td>
						<td align="left" valign="top"><input type="text" name="txtMedicalIns" id="etxtMedicalIns" value="<?php echo $common_func->formatSciNo(@$edit[9]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">失业保险</td>
						<td align="left" valign="top"><input type="text" name="txtLoseWorkIns" id="etxtLoseWorkIns" value="<?php echo $common_func->formatSciNo(@$edit[8]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">生育保险</td>
						<td align="left" valign="top"><input type="text" name="txtMaterIns" id="etxtMaterIns" value="<?php echo $common_func->formatSciNo(@$edit[11]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">住房公积金</td>
						<td align="left" valign="top"><input type="text" name="txtHouseFund" id="etxtHouseFund" value="<?php echo $common_func->formatSciNo(@$edit[12]);?>"/>
						</td>
					  </tr>
					  <tr>
						<td valign="top">生效日期</td>
						<td align="left" valign="top"><input type="text" class="formDateInput" style="margin-left:0px;" name="EffDate" id="EffDate" value="<?php echo (isset($this->postArr['EffDate']))?LocaleUtil::getInstance()->formatDate($this->postArr['EffDate']):LocaleUtil::getInstance()->formatDate($common_func->formatSciNo(@$edit[14])); ?>" size="10" />
	<input type="button"  value="  " class="calendarBtn" name="btnEffDate" /><br class="clear" />
						</td>
					  </tr>
                  </table>
<?php			if(!$supervisorEMPMode && $locRights['edit']) { ?>
<div class="formbuttons">
    <input type="button" class="savebutton" name="btnEditPayment" id="btnEditPayment"
    	value="<?php echo $lang_Common_Save;?>"
    	title="<?php echo $lang_Common_Save;?>"
    	onmouseover="moverButton(this);" onmouseout="moutButton(this);"
    	onclick="editEXTPayment(); return false;"/>
    <input type="reset" class="resetbutton" value="<?php echo $lang_Common_Reset; ?>" />
</div>
<?php			}  ?>
       </div>
<?php } 
$rset = $this->popArr['rsetPayment'];
$currlist=$this->popArr['currAlllist'];


} ?>
</div>
